package com.kernel;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.util.Properties;

/****************************************
 * @name Init
 * @description 初始化配置项类
 * @author 黄彬恒
 * @since 2018/7/16
 ***************************************/
class FactoryInit {
    static Properties getPro() {
        Properties pro = new Properties();
        File f = new File("/fruit.properties");    // 找到属性文件
        try {
            if (f.exists()) {    // 文件存在
                pro.load(new FileInputStream(f));    // 读取属性
            } else {
                pro.setProperty("apple", "com.kernel.Apple");
                pro.setProperty("orange", "com.kernel.Orange");
                pro.store(new FileOutputStream(f), "FRUIT CLASS");
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return pro;
    }
}
